home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / test / testFilePack.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-15  |  2.0 KB  |  90 lines

  1. #define NAME     "testFilePack"
  2. #define REVISION "0"
  3. #define ENDCODE_NOCTRLC
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testFilePack
  8.     Author:        SDI
  9.     Distribution:    PD
  10.     Description:    easy file to file packer
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   06.01.97 : wrote to find the read bit error
  15. */
  16.  
  17. #include <pragma/exec_lib.h>
  18. #include <pragma/dos_lib.h>
  19. #include <pragma/xpkmaster_lib.h>
  20. #include <exec/memory.h>
  21. #include "SDI_defines.h"
  22.  
  23. #ifdef __MAXON__
  24.   #define __asm
  25.   #define __saveds
  26. #endif
  27.  
  28. struct Library        *XpkBase        = 0;
  29. ULONG            DosVersion        = 37;
  30. struct RDArgs        *rda            = 0;
  31.  
  32. #define PARAM "FROM/A,TO/A,METHOD"
  33.  
  34. LONG __asm __saveds chunkfunc(register __a1 struct XpkProgress *prog)
  35. {
  36.   switch(prog->xp_Type)
  37.   {
  38.   case XPKPROG_START: PutStr("Start: "); break;
  39.   case XPKPROG_MID: PutStr("\rMid  : "); break;
  40.   case XPKPROG_END: PutStr("\rEnd  : "); break;
  41.   }
  42.  
  43.   if(prog->xp_Type != XPKPROG_END)
  44.     Printf("%4s: %-8s (%3ld%% done, %2ld%% CF, %6ld cps) %s",
  45.       prog->xp_PackerName, prog->xp_Activity, prog->xp_Done,
  46.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  47.   else
  48.     Printf("%4s: %-8s (%3ldK, %2ld%% CF, %6ld cps) %s\033[K\n",
  49.       prog->xp_PackerName, prog->xp_Activity, prog->xp_ULen >> 10,
  50.       prog->xp_CF, prog->xp_Speed, prog->xp_FileName);
  51.  
  52.   Flush(Output());
  53.   return (LONG) SetSignal(0, SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C;
  54. }
  55.  
  56. struct Hook chunkhook = { {0}, (ULONG (*)()) chunkfunc};
  57.  
  58. void main(void)
  59. {
  60.   UBYTE errbuf[XPKERRMSGSIZE+1];
  61.   struct {
  62.     STRPTR from;
  63.     STRPTR to;
  64.     STRPTR method;
  65.   } args = {0,0,0};
  66.  
  67.   if(!(rda = ReadArgs(PARAM, (LONG *) &args, 0)) ||
  68.   !(XpkBase = OpenLibrary(XPKNAME, 3)))
  69.     End(RETURN_FAIL);
  70.  
  71.   if(XpkPackTags(XPK_InName, args.from, XPK_OutName, args.to,
  72.   XPK_PackMethod, args.method, XPK_GetError,
  73.   errbuf, XPK_ChunkHook, &chunkhook, TAG_DONE))
  74.   {
  75.     STRPTR a = errbuf;
  76.     VPrintf("Can't XpkPack: %s\n", &a);
  77.     End(RETURN_FAIL);
  78.   }
  79.  
  80.   End(RETURN_OK);
  81. }
  82.  
  83.  
  84. void end(void)
  85. {
  86.   if(XpkBase)    CloseLibrary(XpkBase);
  87.   if(rda)    FreeArgs(rda);
  88. }
  89.  
  90.